//
//  TaskListController.swift
//  Pomodoro
//
//  Created by zhengju on 2018/3/5.
//  Copyright © 2018年 zhengju. All rights reserved.
//

import UIKit

class TaskListController: UIViewController {

    
    var tableView: UITableView!
    var titleArray: NSMutableArray!
    var addTitle: String?
    override func viewDidLoad() {
        super.viewDidLoad()

        self.view.backgroundColor = UIColor.white
        self.title = "任务列表"
        titleArray = NSMutableArray.init(array: ["任务1","任务2","任务3"])

        
        if addTitle?.count != 0 {
            self.titleArray.add(addTitle as Any)
        }

        initUI()
        
    }
    
    func initUI() {

        tableView = UITableView.init(frame: CGRect.init(x: 0, y:0, width: SCREEN_WIDTH, height: SCREEN_HEIGHT))
        tableView.backgroundColor = UIColor.withRGB(238, 238, 238)
        tableView.delegate = self
        tableView.dataSource = self
        tableView.isScrollEnabled = false
        tableView.register(TaskListCell.classForCoder(), forCellReuseIdentifier: "TaskListCell")
        tableView.tableFooterView = UIView()
        self.view.addSubview(tableView)
        
        let topView = AddTasksView.init(frame: CGRect.init(x: 0, y: 0, width: SCREEN_WIDTH, height: 80))
        tableView.tableHeaderView = topView
        topView.doneAction = {[weak self] (title) in
            self?.titleArray.add(title)
            self?.tableView.reloadData()
        }

    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    

    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}
